{include file="public/header"}
<title>需求列表</title>
</head>
<body>
<nav class="breadcrumb">
    <i class="Hui-iconfont">&#xe67f;</i> 首页
    <span class="c-gray en">&gt;</span> 标签管理
    <span class="c-gray en">&gt;</span> 标签列表
    <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px"
       href="javascript:location.replace(location.href);" title="刷新"><i class="Hui-iconfont">&#xe68f;</i></a>
</nav>
<div class="page-container">
    <form method="get">
        <div class="text-c ">
            创建时间:
            <input type="text" name="start_time" id="countTimestart" onfocus="selecttime(1)" size="17"
                   class="date input-text " readonly style="width:100px"
                   value="{$data['start_time'] ?? ''}">
            -
            <input type="text" name="end_time" id="countTimeend" onfocus="selecttime(2)" size="17"
                   class="date input-text" readonly style="width:100px"
                   value="">
            <span class="select-box inline" style="border: none">


		</span>
            <span class="select-box inline" style="border: none">

            <input type="text" name="name" placeholder="请输入方案名称" style="width:128px" class="input-text  form-control"
                   value="">
            </span>
            <span class="select-box inline" style="border: none">

            <input type="text" name="user_id" placeholder="请输入创建人" style="width:128px"
                   class="input-text  form-control" value="">
            </span>
            <span class="select-box inline">

           	<select name="state" class="select">
			<option value="" selected>状态</option>
                <option value="1">启用</option>
             <option value="2">禁用</option>
            </select>
            </span>
            <span class="select-box inline">
		<select name="category" class="select">
			<option value="" selected>方案类型</option>
            {volist name='goods_category' id='v'}
             <option value="{$v.id}">{$v.title}</option>
            {/volist}

		</select>

		</span>
            <span class="select-box inline">
		<select name="HouseData" class="select ">
			<option value="" selected>户型</option>
            {volist name='HouseData' id='v'}
             <option value="{$v.id}">{$v.title}</option>
            {/volist}

		</select>

		</span>

            <button class="btn btn-success" type="submit"><i class="Hui-iconfont">&#xe665;</i> 搜索</button>

        </div>

    </form>
    <a style="text-decoration:none" class="btn btn-primary add " href="javascript:;" title="新增"><span
            class="label label-primary">新增</span></a>
    <div class="mt-20">
        <div class="title-border">

            <div class="flex2">方案编号</div>
            <div class="flex1">方案名称</div>
            <div class="flex1">小区</div>
            <div class="flex2">户型</div>
            <div class="flex1">方案类型</div>
            <div class="flex1">创建人</div>
            <div class="flex2">创建时间</div>
            <div class="flex1">使用次数</div>
            <div class="flex1">可见范围</div>
            <div class="flex1">状态</div>
            <div class="flex2">操作</div>
        </div>
        {volist name='data' id='vo'}
        <div class="content-border">
            <div class="flex2">{$vo.scheme_no}</div>
            <div class="flex1">{$vo.name}</div>
            <div class="flex1">{$vo.Community}</div>
            <div class="flex2">{$vo.House}</div>
            <div class="flex1">{$vo.schemeCategory}</div>
            <div class="flex1">{$vo.username}</div>
            <div class="flex2">{$vo.creationTime}</div>
            <div class="flex1">{$vo.schemeUse}</div>
            <div class="flex1">{$vo.privates}</div>
            <div class="flex1" style="color: red">{$vo.states}</div>


            <div class="flex2">
                {if condition="$vo.state ==1"}
                <a class="ch-button ch-red jin" data-id="{$vo.plan_id}" data-da="{$vo.state}" href="javascript:;" title="禁用">禁用</a>
                {else}
                <a class="ch-button ch-red jin" data-id="{$vo.plan_id}" data-da="{$vo.state}" href="javascript:;" title="启用">启用</a>
                {/if}
                <a class="ch-button ch-blue edit" data-id="{$vo.plan_id}" href="javascript:;" title="编辑">编辑</a>
                <a class="ch-button ch-gray info" data-id="{$vo.plan_id}" href="javascript:;" title="查看下一级">查看</a>


            </div>
        </div>
        {/volist}
        <div class="pages" style="float: right">{$data->render()}</div>

    </div>
</div>

{include file="public/footer"}
<script type="text/javascript">

    function selecttime(flag) {
        if (flag == 1) {
            var endTime = $("#countTimeend").val();
            if (endTime != "") {
                WdatePicker({dateFmt: 'yyyy-MM-dd', maxDate: endTime})
            } else {
                WdatePicker({dateFmt: 'yyyy-MM-dd'})
            }
        } else if (flag == 2) {
            var startTime = $("#countTimestart").val();
            if (startTime != "") {
                WdatePicker({dateFmt: 'yyyy-MM-dd', minDate: startTime})
            } else {
                WdatePicker({dateFmt: 'yyyy-MM-dd'})
            }
        } else {
            WdatePicker({dateFmt: 'yyyy-MM-dd'})
        }
    }
    var winWidth = $(window).width();
    var areaWidth = "";
    var areaHeight = "";
    /**
     * 接单提醒
     */
    $('.add').click(function () {
        var tmpIndex = '';
        if (winWidth > 768) {
            areaWidth = "70%"
            areaHeight = "90%"
        } else {
            areaWidth = '70%'
            areaHeight = '90%'
        }
        var src = "{:Url('index/scheme/add')}?id=";
        layer.open({
            type: 2,
            area: [areaWidth, areaHeight],
            fix: true,
            maxmin: true,
            shade: 0.4,
            title: '创建方案',
            content: src,
            success: function (layero, index) {
                var iframeWin = window[layero.find('iframe')[0]['name']];//【核心】
                var v = iframeWin.get();    //调用子页面的方法
                tmpIndex = v;
            },
            cancel: function () {
                localStorage.removeItem(tmpIndex)
            }
        })
    });

    $('.info').click(function () {
        if (winWidth > 768) {
            areaWidth = "90%"
            areaHeight = "90%"
        } else {
            areaWidth = '90%'
            areaHeight = '90%'
        }
        var id = $(this).attr('data-id');
        var src = "{:Url('index/scheme/info')}";
        layer.open({
            type: 2,
            area: [areaWidth, areaHeight],
            fix: true,
            maxmin: true,
            shade: 0.4,
            title: '查看详情',
            content: src + '?id=' + id
        });
    });

    /**
     * 删除
     */
    $('.jin').click(function () {
        var id = $(this).attr('data-id');
        var state = $(this).attr('data-da');
        var obj = {};
        obj.id = id;

        var src = "{:Url('index/scheme/del')}";
        var  msg='';
        if(state ==1){
            msg='确认要禁用吗？';
            obj.msg = 2;
        }else {
            msg='确认要启用吗？';
            obj.msg = 1;
        }
        layer.confirm(msg, function (index) {
            $.ajax({
                type: 'POST',
                url: src,
                dataType: 'json',
                data: obj,
                success: function (data) {
                    var res = JSON.parse(data);
                    if (res.code == 200) {
                        layer.msg(res.msg, {icon: 1, time: 2000}, function () {
                            setTimeout("window.location.reload()", 1);
                        });
                    } else {
                        layer.msg(res.msg, {icon: 5, time: 1000});
                    }

                },
                error: function (data) {
                    console.log(data.msg);
                },
            });
        });
    });

    $('.edit').click(function () {
        if (winWidth > 768) {
            areaWidth = "70%"
            areaHeight = "90%"
        } else {
            areaWidth = '70%'
            areaHeight = '90%'
        }
        var id = $(this).attr('data-id');
        var src = "{:Url('index/scheme/edit')}";

        layer.open({
            type: 2,
            area: [areaWidth, areaHeight],
            fix: true,
            maxmin: true,
            shade: 0.4,
            title: '编辑渠道',
            content: src + '?id=' + id,
            success: function (layero, index) {
                console.log(11)
                var iframeWin = window[layero.find('iframe')[0]['name']];//【核心】
                var v = iframeWin.get();    //调用子页面的方法
                tmpIndex = v;
            },
            cancel: function () {
                localStorage.removeItem(tmpIndex)
            }
        })


    });

</script>
</body>
</html>